home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Wakeup time checker *)
- (* *)
- (* Copyright 1988, 1989 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- (*===========================================================================*)
- (* Wakeup line processor *)
- (*===========================================================================*)
-
- PROCEDURE time_check;
-
- VAR
- code : INTEGER;
- i : INTEGER;
- next_hour : BOOLEAN;
- s : STRING[3];
-
- {$UNDEF DEBUG_TC}
-
- BEGIN;
-
- time_ok := FALSE;
-
- IF time_increment AND (POS('=', action_time_str) > 0) THEN
- BEGIN;
- window_write('WKE:',
- 'Invalid WAKEUP time (+==) on line #' + line_no_str);
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Convert action time to ticks since midnight *)
- (*-----------------------------------------------------------------------*)
-
- colon_pos := POS(':', action_time_str);
-
- IF (colon_pos = 1) OR (colon_pos = LENGTH(action_time_str)) THEN
- BEGIN;
- window_write('WKE:',
- 'Invalid WAKEUP time (colon position) on line #' + line_no_str);
- EXIT;
- END;
-
- IF colon_pos > 0 THEN
- DEC(colon_pos);
-
- (*-----------------------------------------------------------------------*)
- (* Get the HOURS field *)
- (*-----------------------------------------------------------------------*)
-
- s := substr(action_time_str, 1, colon_pos);
-
- IF s <> '==' THEN
- BEGIN;
-
- eq_sw := FALSE;
-
- VAL(s, i, code);
-
- IF (code <> 0) OR (i < 0) OR (i > 23) THEN
- BEGIN;
- window_write('WKE:',
- 'Invalid WAKEUP time (hours) on line #' + line_no_str);
- EXIT;
- END;
-
- hr := i;
-
- END
- ELSE
- BEGIN;
-
- eq_sw := TRUE;
-
- IF colon_pos = 0 THEN
- BEGIN;
- window_write('WKE:',
- 'Invalid WAKEUP time (==) on line #' + line_no_str);
- EXIT;
- END;
-
- next_hour := COPY(last_time_str, 8, 2) = COPY(todays_date_time, 8, 2);
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Get the MINUTES FIELD *)
- (*-----------------------------------------------------------------------*)
-
- IF colon_pos > 0 THEN
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Minutes exist *)
- (*-------------------------------------------------------------------*)
-
- s := COPY(action_time_str, colon_pos+ 2, 255);
-
- VAL(s, i, code);
-
- IF (code <> 0) OR (i < 0) OR (i > 59) THEN
- BEGIN;
- window_write('WKE:',
- 'Invalid WAKEUP time (minutes) on line #' + line_no_str);
- EXIT;
- END;
-
- END
- ELSE
- i := 0;
-
- time_ok := TRUE;
-
- IF eq_sw THEN
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Hours were '=='... Minutes were not *)
- (*-------------------------------------------------------------------*)
-
- IF (NOT did_today AND (last_hours > 0))
- OR ((i <= last_min) AND NOT next_hour) THEN
- action_time := 0
- ELSE
- action_time := time_next_hour(i);
-
- {$IFDEF DEBUG_TC}
- WRITELN('==:xx ', i, ' -- ', last_min, ' -- ',
- next_hour , ' -- ',
- action_time, ' -- ',
- current_day_time);
- {$ENDIF}
-
- EXIT;
-
- END;
-
- action_time := LONGINT(hr) * ticks_per_hour + WORD(i) * ticks_per_min;
-
- IF time_increment AND (action_time = 0) THEN
- BEGIN;
- window_write('WKE:',
- 'Invalid WAKEUP time increment on line #' + line_no_str);
- time_ok := FALSE;
- EXIT;
- END;
-
- END;